<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .box {
            width: 530px;
            display: flex;
            justify-content: space-between;
        }

        img {
            width: 50px;
            height: 50px;
            border-radius: 25px;
        }

        .box textarea {
            width: 400px;
            height: 50px;
            transition: all 0.7s;
        }

        #xx:focus {
            height: 100px;
        }

        span {
            margin-left: 400px;
            opacity: 0;
            transition: all 0.7s;
        }

        button {
            width: 60px;
            height: 30px;
            background-color: orange;
            border: none;
            border-radius: 5px;
            color: white;
            cursor: pointer;
        }
    </style>
</head>

<body>

    <div class="box">
        <img src="./images/4.webp" alt="">
        <textarea maxlength="200" name="" id="xx" placeholder="发一条友善的评论"></textarea>
        <button>发布</button>
    </div>
    <span>0/200字</span>

    <script>
        const tx = document.querySelector('#tx')
        const span = document.querySelector('span')
        tx.addEventListener('input', function () {
            // ② ：不断取得文本框里面的字符长度, 文本域.value.length
            // console.log(tx.value.length)
            // ③ ：把获得数字给下面文本框 
            span.innerText = tx.value.length + '/200字'
        })
        tx.addEventListener('focus', function () {
            span.style.opacity = 1
        })

        tx.addEventListener('blur', function () {
            span.style.opacity = 0
        })

    </script>
</body>

</html>